<template>
  <div class="all_page">
    <div class="info" v-for="(item, index) in dataArr" :key="index">
      <div class="info_top">
        <p>{{item.prodName}}</p>
        <img :src="require('../../assets/images/order/jiantou.png')" alt="" />
      </div>
      <div class="info_center">
        <div class="img">
          <img
            :src="require('../../assets/images/order/xiaolian.png')"
            alt=""
          />
        </div>
        <div class="content">
          <p>{{ item.cusName }}</p>
          <p>下单时间 {{ item.orderTime }}</p>
          <p>收货人 {{ item.receiver }}</p>
        </div>
      </div>
      <div class="info_down">
        <div class="btn" @click="shouhuo(item.serialNo)">收货</div>
      </div>
    </div>

    <!-- 模态框 -->
    <div class="motai" v-show="isShowMotai">
      <div class="bg"></div>
      <div class="tips">
        <div class="top">是否确认收货？</div>
        <div class="down">
          <div class="l" @click="cancel">取消</div>
          <div class="l" @click="sureShou">确认收货</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { receptOrderApi,SureShouhuoApi } from "../../request/api";
export default {
  data() {
    return {
      isShowMotai: false,
      dataArr: {},
      serialNo:'',
    };
  },
  created() {
    let token = localStorage.getItem("token");
   
    receptOrderApi({
      params: {
        current: 1,
        size: 1,
        keyword: 1,
      },
      headers: {
        "x-auth-token": token,
      },
    }).then((res) => {
      console.log(res);
      this.dataArr = res.data.records;
    });
  },
  methods: {
    shouhuo(serialNo) {
   this.isShowMotai = true;
   this.serialNo = serialNo;
    console.log(this.serialNo);
    },
    cancel() {
      this.isShowMotai = false;
    },
    sureShou(){
      // console.log(1);
      SureShouhuoApi(
        this.serialNo,
      ).then(res=>{
                
          if(res.errCode==0){
             this.$toast.success('发货成功');
             setTimeout(()=>{
               this.isShowMotai = false;
             },1500)
          }
      })
    }
  },
};
</script>

<style lang="less" scoped>
.all_page {
  margin-top: 10px;
  background-color: #f5f5f5;
}
.info {
  padding: 0 20px;
  background-color: #fff;
  margin-top: 10px;
  .info_top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    img {
      width: 16px;
      height: 16px;
      color: #000;
    }
  }
  .info_center {
    width: 100%;
    height: 103px;
    background-color: #fff;
    padding: 16px 0 0 21px;
    box-sizing: border-box;
    display: flex;
    border-bottom: 1px solid #e5e5e5;
    border-top: 1px solid #e5e5e5;
    .img {
      width: 59px;
      height: 59px;
      // border: 1px solid #000;
      img {
        width: 100%;
      }
    }
    .content {
      margin-left: 16px;
      p {
        height: 19px;
        line-height: 19px;
        &:nth-of-type(2) {
          margin: 4px 0;
        }
      }
    }
  }
  .info_down {
    width: 100%;
    height: 50px;
    // border: 1px solid #000;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    .btn {
      width: 70px;
      height: 30px;
      border-radius: 15px;
      background-color: #039;
      text-align: center;
      line-height: 30px;
      color: #fff;
    }
  }
}

.motai {
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  .bg {
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
  }

  .tips {
    width: 260px;
    // height: 123px;
    background-color: #fff;
    position: absolute;
    left: 57px;
    top: 244px;
    .top {
      width: 100%;
      height: 75px;
      // background-color: pink;
      text-align: center;
      line-height: 75px;
      font-size: 18px;
      border-bottom: 1px solid #dedede;
    }

    .down {
      width: 100%;
      height: 42px;
      display: flex;
      .l {
        width: 50%;
        height: 42px;
        line-height: 42px;
        text-align: center;
        &:nth-of-type(1) {
          border-right: 1px solid #dedede;
          box-sizing: border-box;
        }
        &:nth-of-type(2) {
          color: #4287ff;
        }
      }
    }
  }
}
</style>